<?php
namespace app\api\controller;

use app\common\controller\ApiBase;
use think\facade\Request;
use think\facade\Db;
use think\facade\Session;

use app\user\model\Notice as Tongzhi;

class Notice extends ApiBase
{
    protected $noAuth = ['notice','add'];
    
    //通知首页
    public function notice()
    {
        //$today = Tongzhi::where('user_id', UserId())->where('status','0')->whereDay('datetime')->order('datetime asc,id desc')->select();
        $list = Tongzhi::with(['customer'])->where('user_id', UserId())->order('status asc,datetime asc,id desc')->paginate(8);
        $this->result(['lists'=>$list]);
    }
    //新增
    public function add()
    {
        if ($this->request->isPost()) {
            $param = $this->request->param();
            $param['shop_id'] = ShopId();
            $param['user_id'] = UserId();
            Tongzhi::create($param);
            insert_api_log('新增通知');
            $this->result('', '0', '操作成功', 'json');
        }
        $date = date('Y-m-d');
        $this->result(['date'=>$date], '0', '操作成功', 'json');
    }
    
    
    
}
